export const recursionSave = function (obj, index, nameArr, value) {
    let name = nameArr[index]
    if (!obj[name]) {
        obj[name] = {}
    }
    if (index === nameArr.length - 1) {
        obj[name] = value
        return;
    }
    recursionSave(obj[name], index + 1, nameArr, value)
}

export const recursion = function (obj, index, nameArr, key) {
    let name = nameArr[index]
    if (name === key) {
        return obj[name]
    }
    if (!obj[name]) {
        return null;
    }
    if (index === nameArr.length) {
        return null;
    }
    return recursion(obj[name], index + 1, nameArr, key)
}

export const recursionRemove = function (obj, index, nameArr, key) {
    if (index === nameArr.length) {
        return;
    }
    let name = nameArr[index]
    if (name === key) {
        delete obj[name]
    } else {
        recursionRemove(obj[name], index + 1, nameArr, key)
    }
}